package com.lanou3g.musicenjoy.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TabHost;
import android.widget.TabWidget;

import com.lanou3g.musicenjoy.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by dllo on 15/10/21.
 */
public class MVFragment extends Fragment implements TabHost.OnTabChangeListener {
    @Bind(android.R.id.tabs)
    TabWidget tabs;
    @Bind(android.R.id.tabcontent)
    FrameLayout tabcontent;
    @Bind(android.R.id.tabhost)
    TabHost tabhost;
    private FragmentManager manager;
    private String position;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_mv, null);

        tabhost= (TabHost) view.findViewById(android.R.id.tabhost);

        tabhost.setOnTabChangedListener(this);
        //tabhost.setBackgroundColor(0xff9999ff);
        tabhost.setup();
        //最新
        TabHost.TabSpec newTab=tabhost.newTabSpec("newTab");
        View viewNew=inflater.inflate(R.layout.new_item,null);
        newTab.setIndicator(viewNew);
      // newTab.setIndicator("最新");
        newTab.setContent(R.id.newTab);
        tabhost.addTab(newTab);
        //最热
        TabHost.TabSpec hotTab=tabhost.newTabSpec("hotTab");
        View viewHot=inflater.inflate(R.layout.hot_item,null);
        hotTab.setIndicator(viewHot);
   //     hotTab.setIndicator("最热");
        hotTab.setContent(R.id.hotTab);
        tabhost.addTab(hotTab);

        manager=getActivity().getSupportFragmentManager();
        FragmentTransaction transition=manager.beginTransaction();
        transition.replace(R.id.newTab,new NewFragment());
        transition.replace(R.id.hotTab,new HotFragment());
        transition.commit();

        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @Override
    public void onTabChanged(String tabId) {



    }
}
